<!--# layout("/common/layout.html",{"jsBase":"/js/demo/demoBase/"}){ -->

<form class="layui-form layui-form-pane" id="addForm" enctype="multipart/form-data"  lay-filter="editform">
    <input type="hidden" name="demoId" id="demoId">

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">标题</label>
				<div class="layui-input-inline">
                                <input type="text" name="title" id="title" autocomplete="off" class="layui-input" lay-verify="required">
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">单选项</label>
				<div class="layui-input-inline">
					<layui:simpleDictSelect style='layui-input-inline' type="PAY_METHOD" layVerify=""
								id="singleSelect" name="singleSelect" value="" />
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">多选项1</label>
				<div class="layui-input-inline">
                                <select name="mulSelect"  id="mulSelect" lay-verify="">
                                    <option value="">不限制</option>
                                </select>
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">文本</label>
				<div class="layui-input-inline">
                                <textarea name="longTxt"  id="longTxt" placeholder="请输入" class="layui-textarea" ></textarea>
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">本地文件</label>
				<div class="layui-input-inline">
                                    <layui:singleFile id="localFile" tagName="本地文件" tips="说明对文件的限制"/>
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">云文件</label>
				<div class="layui-input-inline">
                                    <layui:singleFile id="cloudFile" tagName="云文件" tips="说明对文件的限制"/>
				</div>
            </div>
        </div>
    </div>

    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
            <label class="layui-form-label">图片</label>
				<div class="layui-input-inline">
                                    <layui:image id="cover" tagName="图片" tips="图片说明"/>
				</div>
            </div>
            <div class="layui-inline">
            <label class="layui-form-label">可用标记</label>
				<div class="layui-input-inline">
                                <input type="radio" name="demoStatus" value="1" title="是">
                                <input type="radio" name="demoStatus" value="0" title="否" checked>
				</div>
            </div>
        </div>
    </div>
    <layui:submitButtons id="addButton" />
</form>
<!--#} -->
<script>
    Common.initImage();
layui.define([ 'form', 'laydate', 'table','demoBaseApi'], function(exports) {
    var form = layui.form;
    var demoBaseApi = layui.demoBaseApi;
    var index = layui.index;
    var isNew = true;
    <!--# if(!(isEmpty(demoBaseJson))){  -->
    isNew = false;
    <!--# } -->
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                form.on('submit(form)', function(){
                    demoBaseApi.saveForm(isNew,$('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("保存成功");
                        Lib.closeFrame();
                    });
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    view.init();
    <!--# if(!(isEmpty(demoBaseJson))){  -->
    var formJson = ${demoBaseJson};
    form.val("editform",formJson);
    $(".image-preview").each(function() {
        $(this).attr("src",formJson[$(this).attr("id")]);
    });
    <!--# } -->
});
</script>
